package com.wondersgroup.fjzlpt.org.service.impl.yljgxx;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.repository.sql.bean.SQLBean;
import com.wondersgroup.fjzlpt.org.dao.inter.yljgxx.YljgxxDAO;
import com.wondersgroup.fjzlpt.org.service.inter.yljgxx.YljgxxService;

@Service
public class YljgxxServiceImpl implements YljgxxService{

	@Autowired
	private YljgxxDAO yljgxxDao;
	
	/**
	 * 分页查询
	 * @param map
	 * @return
	 */
	//@Cacheable("queryPage")
	public JSONObject queryPage(Map<String, String> map)
	{
		return this.yljgxxDao.queryPage(map);
	}
	
	/**
	 * 根据条件查询所有医疗机构
	 * @param map
	 * @return
	 */
	public JSONArray queryList(Map<String, String> map){
		return yljgxxDao.queryList(map);
	}

	/**
	 * 分页查询科室信息
	 * @param request
	 * @return
	 */
	public JSONObject queryPageByKs(Map<String, String> map) {
		JSONObject jo = this.yljgxxDao.queryPage(map);
		JSONArray ja = JSONObject.parseArray(jo.getString("rows"));
		/**获取医疗机构的ID*/
		JSONObject json = new JSONObject();
		List<String> list = new ArrayList<String>();
		if(!ja.isEmpty()){
			Iterator<Object> it = ja.iterator();
			while (it.hasNext()) {
				json = JSONObject.parseObject(it.next().toString());
				list.add(json.getString("PTJGID"));
			}
		}
		StringBuffer sbuf = new StringBuffer();
		sbuf.append("");
		SQLBean sb = new SQLBean();
		sb.setParamAry(list);
		/**获取医疗机构的科室*/
		ja = yljgxxDao.queryList(sb);
		return null;
	}
	
	/**
	 * 查询所有医疗机构信息
	 * @param map
	 * @return
	 */
	public JSONArray queryAll(Map<String, String> map){
		return yljgxxDao.queryAll(map);
	}
	
}




















